import Request_1 from './Request.js'
import Global_1 from './config.js'


/** 用户模块 */
var SocketUser = (function() {
	
	function SocketUser() {}
	
	/** 根据客户端标识登陆 获取 ClientToken */
	SocketUser.prototype.LoginWsByClient = function(paramster, callback) {
		if (!paramster.uuid) {
			console.error("project uuid is null");
			return;
		}
		if (!paramster.projectToken) {
			console.error("project projectToken is null");
			return;
		}
		var request = new Request_1.Request(Global_1.GlobalSocketUser.WsByClient.toString(), paramster);
		request.Then(function(e) {
			if (e.code == 200) {
				callback && callback(e);
			} else {
				console.error(e.info);
			}
		}).Catch(function(a) {
			console.error("请求异常请刷新重试");
		}).Post();
	};
	
	/**
	 * 退出 Ws 登陆
	 * token 为ServiceToken
	 * 原token 仍然有效
	 */
	SocketUser.prototype.OutLoginWs = function(token, callback) {
		if (!token) {
			console.error("token is null");
			return;
		}
		
		var request = new Request_1.Request(Global_1.GlobalSocketUser.OutLoginWs.toString() + token);
		
		request.Then(function(e) {
			
		}).Catch(function(a) {
			console.error("请求异常请刷新重试");
		}).Delete();
	};
	return SocketUser;
}());


export default { SocketUser:SocketUser };
